﻿<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
	<asp:ScriptManager ID="ScriptManager1" runat="server">
	</asp:ScriptManager>
	<div>
		<asp:UpdatePanel ID="UpdatePanel1" runat="server">
			<ContentTemplate>
				<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
					ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"
				   
					SelectCommand="SELECT [ProductID], [Name], [ProductNumber], [MakeFlag], [SafetyStockLevel], [ReorderPoint] FROM [Production].[Product]" 
					DeleteCommand="DELETE FROM [Production].[Product] WHERE [ProductID] = @ProductID" 
					InsertCommand="INSERT INTO [Production].[Product] ([Name], [ProductNumber], [MakeFlag], [SafetyStockLevel], [ReorderPoint]) VALUES (@Name, @ProductNumber, @MakeFlag, @SafetyStockLevel, @ReorderPoint)" 
					UpdateCommand="UPDATE [Production].[Product] SET [Name] = @Name, [ProductNumber] = @ProductNumber, [MakeFlag] = @MakeFlag, [SafetyStockLevel] = @SafetyStockLevel, [ReorderPoint] = @ReorderPoint WHERE [ProductID] = @ProductID" >
					<DeleteParameters>
						<asp:Parameter Name="ProductID" Type="Int32" />
					</DeleteParameters>
					<UpdateParameters>
						<asp:Parameter Name="Name" Type="String" />
						<asp:Parameter Name="ProductNumber" Type="String" />
						<asp:Parameter Name="MakeFlag" Type="Boolean" />
						<asp:Parameter Name="SafetyStockLevel" Type="Int16" />
						<asp:Parameter Name="ReorderPoint" Type="Int16" />
						<asp:Parameter Name="ProductID" Type="Int32" />
					</UpdateParameters>
					<InsertParameters>
						<asp:Parameter Name="Name" Type="String" />
						<asp:Parameter Name="ProductNumber" Type="String" />
						<asp:Parameter Name="MakeFlag" Type="Boolean" />
						<asp:Parameter Name="SafetyStockLevel" Type="Int16" />
						<asp:Parameter Name="ReorderPoint" Type="Int16" />
					</InsertParameters>
				</asp:SqlDataSource>
				<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
					AllowSorting="True" AutoGenerateColumns="False"
					DataKeyNames="ProductID" DataSourceID="SqlDataSource1" CellPadding="4" 
                    ForeColor="#333333" GridLines="None">
					<FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
					<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
					<Columns>
						<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
							ButtonType="Button" ShowSelectButton="True" />
						<asp:BoundField DataField="ProductID" HeaderText="ProductID" 
							InsertVisible="False"
							ReadOnly="True" SortExpression="ProductID" />
						<asp:BoundField DataField="Name" HeaderText="Name" 
							SortExpression="Name" />
						<asp:BoundField DataField="ProductNumber" 
							HeaderText="ProductNumber" SortExpression="ProductNumber" />
						<asp:CheckBoxField DataField="MakeFlag" 
							HeaderText="MakeFlag" SortExpression="MakeFlag" />
						<asp:BoundField DataField="SafetyStockLevel" 
							HeaderText="SafetyStockLevel" SortExpression="SafetyStockLevel" />
						<asp:BoundField DataField="ReorderPoint" 
							HeaderText="ReorderPoint" SortExpression="ReorderPoint" />
					</Columns>
					<PagerStyle ForeColor="White" HorizontalAlign="Center" BackColor="#284775" />
					<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
					<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
				    <EditRowStyle BackColor="#999999" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
				</asp:GridView>
				<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
				<asp:TextBox ID="txtName" runat="server" ReadOnly="True"></asp:TextBox>
				<br />
				<asp:GridView ID="GridView2" runat="server" 
					DataSourceID="AdventureWorksOrderDetails" BackColor="#DEBA84" BorderColor="#DEBA84" 
					BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
					<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
					<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
					<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
					<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
					<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
				</asp:GridView>
				<asp:SqlDataSource ID="AdventureWorksOrderDetails" runat="server" 
					ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>" 
					SelectCommand="SELECT [SalesOrderID], [CarrierTrackingNumber], [OrderQty], [UnitPrice], 
						[UnitPriceDiscount], [LineTotal] 
						FROM [Sales].[SalesOrderDetail] 
						WHERE ([ProductID] = @ProductID) 
						ORDER BY [SalesOrderID]">
					<SelectParameters>
						<asp:ControlParameter 
							ControlID="GridView1" 
							Name="ProductID" 
							PropertyName="SelectedValue" 
							Type="Int32" />
					</SelectParameters>
				</asp:SqlDataSource>
			</ContentTemplate>
		</asp:UpdatePanel>
	</div>
	</form>
</body>
</html>
